package logic

import (
	"context"
	"person/model/mysql"

	"person/personrpc/internal/svc"
	"person/personrpc/personrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *personrpc.ShowRequest) (*personrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var use mysql.Use
	mysql.DB.Debug().Where("id=?", in.Id).Find(&use)
	return &personrpc.ShowResponse{
		Id:       int64(use.ID),
		Account:  use.Account,
		Password: use.Password,
	}, nil
}
